#include "Tile.h"
#include "Character.h"

Tile::Tile() : Mappable() {
	type_ = Node::NODE_TILE;
	visibility_ = TILE_VISIBILITY::TILE_UNSEEN;
	cha_ = NULL;
}

Tile::Tile(TILE_TYPE tileType) : Tile() {
	tileType_ = tileType;
}

Tile::~Tile() {

}

int Tile::getTileType() {
	return tileType_;
}

bool Tile::isPassable() {
	switch (tileType_) {
	case TILE_TYPE::TILE_WALL:
	case TILE_TYPE::TILE_UNBREAKABLE:
			return false;
	default:
		break;
	}
	return true;
}

void Tile::createTile(TILE_TYPE tileType) {
	tileType_ = tileType;
}

bool Tile::setChaOnTile(Character* cha) {
	cha_ = cha;
	if (cha == NULL)
		return true;
	cha_->setTileUnderCha(this);
	int x, y;
	getPos(x, y);
	cha_->setPos(x, y);
	return true;
}

void Tile::addItemOnTile(Mappable* item) {
	lstItem_.push_back(item);
}